home *** CD-ROM | disk | FTP | other *** search
/ Software Vault: The Diamond Collection / The Diamond Collection (Software Vault)(Digital Impact).ISO / cdr49 / vesa18.zip / VESA_TR8.DRV < prev    next >
Internet Message Format  |  1994-12-07  |  23KB

  1. From calle@erix.ericsson.se Wed Dec  7 08:27:23 1994
  2. Date: Wed, 7 Dec 94 09:36:46 +0100
  3. From: Carl Wilhelm Welin <calle@erix.ericsson.se>
  4. To: z946785@corn.cso.niu.edu
  5. Subject: Trident driver asm code
  6.  
  7.  
  8. Hello,
  9.  
  10. excuse me for this long letter. I included also some documentation I thought
  11. might be useful. First comes DRIVERS.DOC documenting the drivers which come
  12. with the LIBGRX graphics package for DJGPP. The driver which works with my
  13. card is TRID89N.GRD, an "old style driver" (see below). The "new style driver"
  14. TR8900.GRN doesn't work, it gives random pixels all over the screen.
  15. Then comes an include file GRDRIVER.INC, which seems to be used when
  16. assembling TRID89N.ASM, and the other drivers. Last comes the actual driver
  17. source file, TRID89N.ASM. Thanks a lot for all your help so far.
  18.  
  19. Best wishes,
  20. Calle
  21.  
  22. /* This is file DRIVERS.DOC from LIBGRX package contributed to DJGPP */
  23.  
  24. Abstract
  25.  
  26. This document  describes the  graphics driver  format used  for DJGPP and  the
  27. LIBGRX  graphics library.  It also gives  hints for  creating a  driver for an
  28. unsupported display adapter. 
  29.  
  30. Introduction
  31.  
  32. The DJGPP graphics drivers do two things:
  33.  
  34.   (1) Invoke the BIOS INT 10 routine for setting up the desired graphics mode.
  35.       Different boards  support different  resolutions and use  different mode
  36.       numbers -- that's why different drivers are needed for different boards.
  37.  
  38.   (2) Implement page  mapping for video modes which use more than 64K of video
  39.       memory. This is again board dependent.
  40.  
  41. Old driver format
  42.  
  43. The  following C  declarations  describe the  header of  an  old format  DJGPP
  44. graphics driver. Of course, real drivers are coded in assembly. 
  45.  
  46. typedef unsigned short u_short;
  47.      typedef unsigned char  u_char;
  48.  
  49.      struct old_driver_header {
  50.          u_short      mode_set_routine_offset;
  51.          u_short      paging_routine_offset;
  52.          u_short      paging_mode_flag;    /* 0 if no separate R/W, 1 if yes */
  53.          u_short      default_text_width;
  54.          u_short      default_text_height;
  55.          u_short      default_graphics_width;
  56.          u_short      default_graphics_height;
  57.      };
  58.  
  59. The mode set routine does the following:
  60.  
  61. ;--------------------------------------------------------------------------
  62.      ; Entry: AX=mode selection
  63.      ;                0=80x25 text
  64.      ;                1=default text
  65.      ;                2=text CX cols by DX rows
  66.      ;                3=biggest text
  67.      ;                4=320x200 graphics
  68.      ;                5=default graphics
  69.      ;                6=graphics CX width by DX height
  70.      ;                7=biggest non-interlaced graphics
  71.      ;                8=biggest graphics
  72.      ;         CX=width (in pixels or characters) (not always used -- depends on AX)
  73.      ;         DX=height
  74.      ;
  75.      ; NOTE: This runs in real mode, but don't mess with the segment registers.
  76.      ;
  77.      ; Exit:  CX=width (in pixels or characters)
  78.      ;         DX=height
  79. ;------------------------------------------------------------------------
  80.  
  81. The paging routine does the following:
  82.  
  83. ;--------------------------------------------------------------------------
  84.      ; Entry: AH=read page
  85.      ;         AL=write page
  86.      ;
  87.      ; NOTE: This runs in protected mode!  Don't mess with the segment registers!
  88.      ; This code must be relocatable and may not reference any data!
  89.      ;
  90.      ; Exit: VGA configured.
  91.      ;        AX,BX,CX,DX,SI,DI may be trashed
  92. ;--------------------------------------------------------------------------
  93.  
  94. The old style  graphics driver structure  remained unchanged for the  first 16
  95. color drivers developed for LIBGRX. The only difference is that the additional
  96. 15  bits in the  third word of  the header were  given new meanings.  (The 256
  97. color  DJGPP  library only  used  one  bit to  encode  the  capability to  map
  98. different pages for  reading and writing.) The  values of these new  bitfields
  99. were assigned as to stay compatible with the existing 256 color drivers. (I.e.
  100. the  0  value  in every  bitfield  selects  the  256  color VGA  option.)  The
  101. definition of these bits (from "grdriver.h"):
  102.  
  103. #define GRD_NEW_DRIVER    0x0008         /* NEW FORMAT DRIVER IF THIS IS SET */
  104.  
  105. #define GRD_PAGING_MASK   0x0007         /* mask for paging modes */
  106. #define GRD_NO_RW         0x0000         /* standard paging, no separate R/W */
  107. #define GRD_RW_64K        0x0001         /* two separate 64K R/W pages */
  108. /* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */
  109. /* THE FOLLOWING THREE OPTIONS ARE NOT SUPPORTED AT THIS TIME             */
  110. #define GRD_RW_32K        0x0002         /* two separate 32Kb pages */
  111. #define GRD_MAP_128K      0x0003         /* 128Kb memory map -- some Tridents
  112.                                             can do it (1024x768x16 without
  113.                                             paging!!!) */
  114. #define GRD_MAP_EXTMEM    0x0004           /* Can be mapped extended, above 1M.
  115.                                               Some Tseng 4000-s can do it, NO
  116.                                               PAGING AT ALL!!!! */
  117. /* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */
  118.  
  119. #define GRD_TYPE_MASK     0xf000           /* adapter type mask */
  120. #define GRD_VGA           0x0000           /* vga */
  121. #define GRD_EGA           0x1000           /* ega */
  122. #define GRD_HERC          0x2000           /* hercules */
  123. #define GRD_8514A         0x3000           /* 8514/A or compatible */
  124. #define GRD_S3            0x4000           /* S3 graphics accelerator */
  125. #define GRD_PLANE_MASK    0x0f00           /* bitplane number mask */
  126. #define GRD_8_PLANES      0x0000           /* 8 planes = 256 colors */
  127. #define GRD_4_PLANES      0x0100           /* 4 planes = 16 colors */
  128. #define GRD_1_PLANE       0x0200           /* 1 plane  = 2 colors */
  129. #define GRD_16_PLANES     0x0300           /* VGA with 32K colors */
  130. #define GRD_8_X_PLANES    0x0400           /* VGA in mode X w/ 256 colors */
  131. #define GRD_MEM_MASK      0x00f0           /* memory size mask */
  132. #define GRD_64K           0x0010           /* 64K display memory */
  133. #define GRD_128K          0x0020           /* 128K display memory */
  134. #define GRD_256K          0x0030           /* 256K display memory */
  135. #define GRD_512K          0x0040           /* 512K display memory */
  136. #define GRD_1024K         0x0050           /* 1MB display memory */
  137. #define GRD_192K          0x0060           /* 192K -- some 640x480 EGA-s */
  138. #define GRD_M_NOTSPEC     0x0000           /* memory amount not specified */
  139.  
  140. An old style  driver has the  'GRD_NEW_DRIVER' bit cleared.  It can work  with
  141. previous versions of GO32. Of course  for 16 color support the application has
  142. to be  linked  with the  LIBGRX  library instead  of  the original  256  color
  143. library.
  144.  
  145. The following additional  old format  graphics drivers are  supplied with  the
  146. LIBGRX graphics library:
  147.  
  148.       EGA16.GRD         16 color EGA driver (640x350x16 max. resolution)
  149.       VGA16.GRD         16   color  standard   VGA  driver   (640x480x16  max.
  150.                         resolution)
  151.       TSENG4KN.GRD      same as  DJGPP's Tseng ET  4000 256 color  driver, but
  152.                         with  added support  for the  100x40 text  mode. (max:
  153.                         1024x768x256)
  154.       TSENG416.GRD      Tseng ET 4000 16 color driver. (max: 1024x768x16)
  155.       TRID89N.GRD       Trident  8900 256  color  driver. This  driver has  an
  156.                         updated  paging  routine  which  seems   to  fix  some
  157.                         previous   problems  on  boards   with  recent  enough
  158.                         chipsets. (max: 1024x768x256)
  159.       TRID8916.GRD:     Trident 8900 16 color driver (max: 1024x768x16)
  160.  
  161.  
  162. New driver format
  163.  
  164. The disadvantage of the old  driver format is that the number of colors is not
  165. programmable. The new driver format solves  this problem and it also gives the
  166. application program a way to query the driver for a list of the supported text
  167. and graphics modes. For this the driver header was extended as follows:
  168.  
  169. struct new_driver_header {
  170.    u_short      mode_set_routine_offset;
  171.    u_short      paging_routine_offset;
  172.    u_short      driver_mode_flag;        /* flag word, see bits below */
  173.    u_short      default_text_width;
  174.    u_short      default_text_height;
  175.    u_short      default_graphics_width;
  176.    u_short      default_graphics_height;
  177.    u_short      default_color_number;    /* NEW, may be set from environment */
  178.    u_short      init_routine_offset;     /* NEW, call once after drvr loaded */
  179.    u_short      text_mode_table_offset;  /* NEW, table of supported text modes */
  180.    u_short      graphics_mode_table_offset;  /* NEW, table of supported graphics modes */
  181.      };
  182.  
  183.  
  184. 'text_mode_table_offset' points to a table with entries as follows:
  185.  
  186. struct text_mode_entry {
  187.    u_short      columns;
  188.    u_short      rows;
  189.    u_short      number_of_colors; /* in text mode it is mainly here to make
  190.                                      GCC happy with the alignments */
  191.    u_char       BIOS_mode;        /* BIOS mode number. Mode not available on
  192.                                      the current card if this field is 0xff. */
  193.    u_char       special;          /* if non zero then the driver does some
  194.                                      special hacks to set it up (like
  195.                                      the 50 row mode on a standard VGA) */
  196.      };
  197.  
  198. The end of the table is marked by an all 0 entry. The table entries are sorted
  199. by  increasing size. The field 'graphics_mode_table_offset'  points to a table
  200. with entries as follows:
  201.  
  202. struct graphics_mode_entry {
  203.    u_short      width;
  204.    u_short      height;
  205.    u_short      number_of_colors;
  206.    u_char       BIOS_mode;        /* BIOS mode number. Mode not available on
  207.                                      the current card if this field is 0xff.
  208.                                      (This may happen for example if the card
  209.                                      is not fully populated with RAM) */
  210.    u_char       special;          /* if non zero then the driver does some
  211.                                      special hacks to set it up (like
  212.                                      setting up the 32768 color mode on
  213.                                      some ET4000 cards) */
  214.      };
  215.  
  216. The end  of the  table is marked  by an all  0 entry.  The table is  sorted by
  217. increasing color number and within the same color modes by increasing size.
  218.  
  219. If  the driver  is of  the new type  then it  also supports  an initialization
  220. routine. This  is called once after  the driver is  loaded. The initialization
  221. routine can do one or more of the following:
  222.  
  223.   (1) Check whether the video card is of the expected type
  224.  
  225.   (2) Determine the amount of video memory on board.
  226.  
  227.   (3) Determine which  of the modes in  the text and graphics  mode tables are
  228.       actually available (due to  video RAM and possibly DAC  [32768 colors!!]
  229.       limitations) and mark the unavailable entries in the tables.
  230.  
  231. To use the new format drivers a recent version of GO32 (1.06, after the middle
  232. of  April  1992) has  to  be  used. Such  versions  should  recognize the  "nc
  233. <number>"  option field in the  GO32 environment variable  which specifies the
  234. default number of colors for the driver.
  235.  
  236. The  following new format drivers  have been included  with the LIBGRX library
  237. (new drivers have the ".GRN" extension):
  238.  
  239.       STDEGA.GRN        standard EGA 16 color driver
  240.       STDVGA.GRN        standard VGA 16 and 256 color driver
  241.       ET4000.GRN        Tseng ET 4000 16 256 and 32768 color driver
  242.       TR8900.GRN        Trident 8900 16 and 256 color driver
  243.       ATIULTRA.GRN      Driver for  the ATI  ULTRA board. This  board actually
  244.                         contains two graphics adapters: a 512 KByte SVGA board
  245.                         and a  8514/A compatible  accelerator. The driver  was
  246.                         programmed  to use  the VGA  part for  text,  16 color
  247.                         graphics, and low resolution  256 color graphics modes
  248.                         and  the 8514/A  part  for high  resolution 256  color
  249.                         modes.  This driver  should work  with any  VGA+8514/A
  250.                         (the  8514/A  MUST   have  1MB  memory   for  1024x768
  251.                         resolution)  combination as  long as  the ATI-specific
  252.                         modes of the VGA part are not used.
  253.       STEALTH.GRN Driver  for  the  Diamond  Stealth  S3 graphics  accelerator
  254.                   board.  The driver was programmed to use VGA-style video RAM
  255.                   access  for text, 16 color  graphics, and low resolution 256
  256.                   color graphics  modes and  the S3 accelarator  functions for
  257.                   high resolution  256 color  modes. Currently no  32768 color
  258.                   modes are supported  on S3 boards.  This driver should  work
  259.                   with other S3-based boards which have a VESA BIOS.
  260.  
  261.  
  262. Creating a driver for an unsupported board
  263.  
  264. You can  only use EGA or  VGA boards in 16  256 or 32768 color  modes with the
  265. graphics library. In the near future there will be support for Hercules boards
  266. as well. SUPPORT IS NOT PLANNED FOR: BOARDS  WITH ON-BOARD GRAPHICS PROCESSORS
  267. (TIGA, 8514A, etc...) To create a  driver for an unsupported EGA or  VGA board
  268. you will need the followings:
  269.  
  270.   (1) An  assembler (TASM or MASM), a linker (TLINK  or LINK) and a utility to
  271.       convert .EXE files to the .COM format (EXE2BIN). See also the 'makefile'
  272.       in the 'drivers' sub-directory.
  273.   (2) A  documentation of the board containing the supported BIOS mode numbers
  274.       and resolutions. 
  275.   (3) If the driver needs to support modes which use a  memory map bigger than
  276.       64K then you also need a piece of code which does page switching on your
  277.       board. (Any  mode above 800x600  in 16 colors  or 320x200 in  256 colors
  278.       DOES USE paging.) Possible sources:
  279.           - a working, tested  256 color  original DJGPP driver  (if you  just
  280.             want to convert it to the new format).
  281.           - VGAKIT.ZIP (available from various archive sites,  like wuarchive,
  282.             simtel, etc...)
  283.           - various books on the subject.
  284.  
  285. It is best to start with the source of a driver supporting similar resolutions
  286. as your board.  Use the proper format  driver, i.e. if  you want a new  format
  287. driver start  with a  new original,  etc... Typically  the driver  sources are
  288. relatively well commented. What you need to do is:
  289.  
  290.   (1) possibly change  the option word at  the head of the  driver to indicate
  291.       the  number of colors (old format only),  the amount of memory on board,
  292.       the memory mapping capabilities of the board. 
  293.   (2) change the mode setting code to use the proper BIOS mode numbers. In the
  294.       old  format drivers these are somewhat scattered throughout the code, in
  295.       the new format drivers you need to edit a few tables only.
  296.   (3) Replace the paging routine with the one suitable for your board. If your
  297.       driver supports 16  color resolutions  beyond 800x600 then  you have  to
  298.       make sure that upon exit from the paging routine the graphics controller
  299.       port's (0x3ce)  index register is reset to 8. (See the paging routine in
  300.       "TR8900.ASM".)  If  the paging  mechanism  does  not  use  any  register
  301.       accessed  through the graphics controller  port, then you  don't need to
  302.       worry about this.
  303.  
  304. /* End of file DRIVERS.DOC */
  305.  
  306.  
  307.  
  308.  
  309.  
  310. ;; This is file GRDRIVER.INC
  311. ;;
  312. ;; Copyright (c) 1991 DJ Delorie, 24 Kirsten Ave, Rochester NH 03867-2954
  313. ;; Copyright (C) 1992 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221
  314. ;;
  315. ;; This file is distributed under the terms listed in the document
  316. ;; "copying.dj", available from DJ Delorie at the address above.
  317. ;; A copy of "copying.dj" should accompany this file; if not, a copy
  318. ;; should be available from where this file was obtained.  This file
  319. ;; may not be distributed without a verbatim copy of "copying.dj".
  320. ;;
  321. ;; This file is distributed WITHOUT ANY WARRANTY; without even the implied
  322. ;; warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  323. ;;
  324.  
  325. ;; ==================================================================
  326. ;;             DRIVER FLAG BITS
  327. ;; ==================================================================
  328.  
  329. GRD_NEW_DRIVER  equ 0008h    ;; NEW FORMAT DRIVER IF THIS IS SET
  330.  
  331. GRD_PAGING_MASK equ 0007h    ;; mask for paging modes
  332. GRD_NO_RW    equ 0000h    ;; standard paging, no separate R/W
  333. GRD_RW_64K    equ 0001h    ;; two separate 64K R/W pages
  334. ;; !!! THE FOLLOWING THREE OPTIONS ARE NOT SUPPORTED AT THIS TIME !!!
  335. GRD_RW_32K    equ 0002h    ;; two separate 32Kb pages
  336. GRD_MAP_128K    equ 0003h    ;; 128Kb memory map -- some Tridents do it
  337. GRD_MAP_EXTMEM  equ 0004h    ;; Can be mapped extended, above 1M.
  338. ;; !!!
  339.  
  340. GRD_TYPE_MASK    equ f000h    ;; adapter type mask
  341. GRD_VGA        equ 0000h    ;; vga
  342. GRD_EGA        equ 1000h    ;; ega
  343. GRD_HERC    equ 2000h    ;; hercules
  344. GRD_8514A    equ 3000h    ;; IBM 8514A or compatible
  345. GRD_S3        equ 4000h    ;; S3 graphics accelerator
  346. ;; ++ GRX 1.03 ".VDR" format
  347. GRD_W9000    equ 5000h    ;; Weitek 9000 accelerator
  348.  
  349. GRD_PLANE_MASK  equ 0f00h    ;; bitplane number mask
  350. GRD_8_PLANES    equ 0000h    ;; 8 planes = 256 colors
  351. GRD_4_PLANES    equ 0100h    ;; 4 planes = 16 colors
  352. GRD_1_PLANE    equ 0200h    ;; 1 plane = 2 colors
  353. GRD_16_PLANES    equ 0300h    ;; VGA with 32K colors (really only 15 planes)
  354. GRD_8_X_PLANES  equ 0400h    ;; VGA in mode X w/ 256 colors
  355. ;; ++ GRX 1.03 ".VDR" format
  356. GRD_8_F_PLANES  equ 0500h    ;; VGA 256c switchable betw. linear and modeX
  357. GRD_16_R_PLANES equ 0600h    ;; The "real" 16 plane mode with 64K colors
  358. GRD_24_PLANES    equ 0700h    ;; 24 plane "TrueColor" mode
  359.  
  360. GRD_MEM_MASK    equ 00f0h    ;; memory size mask
  361. GRD_M_NOTSPEC    equ 0000h    ;; memory amount not specified
  362. GRD_64K        equ 0010h    ;; 64K display memory
  363. GRD_128K    equ 0020h    ;; 128K display memory
  364. GRD_256K    equ 0030h    ;; 256K display memory
  365. GRD_512K    equ 0040h    ;; 512K display memory
  366. GRD_1024K    equ 0050h    ;; 1MB display memory
  367. GRD_192K    equ 0060h    ;; 192K -- some 640x480 EGA-s
  368. ;; ++ GRX 1.03 ".VDR" format
  369. GRD_1536K    equ 0070h    ;; 1.5 MB
  370. GRD_2048K    equ 0080h    ;; 2.0 MB
  371. GRD_3072K    equ 0090h    ;; 3.0 MB
  372. GRD_4096K    equ 00a0h    ;; 4.0 MB
  373.  
  374. ; End of file GRDRIVER.INC
  375.  
  376.  
  377.  
  378.  
  379. ; This is file TRID89N.ASM
  380. ;
  381. ; Copyright (C) 1991 DJ Delorie, 24 Kirsten Ave, Rochester NH 03867-2954
  382. ;
  383. ; This file is distributed under the terms listed in the document
  384. ; "copying.dj", available from DJ Delorie at the address above.
  385. ; A copy of "copying.dj" should accompany this file; if not, a copy
  386. ; should be available from where this file was obtained.  This file
  387. ; may not be distributed without a verbatim copy of "copying.dj".
  388. ;
  389. ; This file is distributed WITHOUT ANY WARRANTY; without even the implied
  390. ; warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  391. ;
  392.  
  393. include grdriver.inc
  394. cseg    segment byte public 'code'
  395.     assume  cs:cseg, ds:cseg, es:cseg, ss:nothing
  396.  
  397.     dw    offset init_routine
  398.     dw    offset paging_routine
  399.     dw    GRD_VGA+GRD_8_PLANES+GRD_1024K+GRD_NO_RW
  400.  
  401. def_tw  dw    80    ; filled in by go32 if GO32 env. var. is set
  402. def_th  dw    25
  403. def_gw  dw    640
  404. def_gh  dw    480
  405.  
  406. ;--------------------------------------------------------------------------
  407. ; Entry: AX=mode selection
  408. ;        0=80x25 text
  409. ;        1=default text
  410. ;        2=text CX cols by DX rows
  411. ;        3=biggest text
  412. ;        4=320x200 graphics
  413. ;        5=default graphics
  414. ;        6=graphics CX width by DX height
  415. ;        7=biggest non-interlaced graphics
  416. ;        8=biggest graphics
  417. ;
  418. ; NOTE: This runs in real mode, but don't mess with the segment registers.
  419. ;
  420. ; Exit:  CX=width (in pixels or characters)
  421. ;     DX=height
  422.  
  423. init_table    label    word
  424.     dw    offset init_0
  425.     dw    offset init_1
  426.     dw    offset init_2
  427.     dw    offset init_3
  428.     dw    offset init_4
  429.     dw    offset init_5
  430.     dw    offset init_6
  431.     dw    offset init_7
  432.     dw    offset init_8
  433.  
  434. init_routine    proc    far
  435.     cmp    ax,8
  436.     jbe    valid_req
  437.     ret
  438. valid_req:
  439.     shl    ax,1
  440.     mov    bx,ax
  441.     jmp    init_table[bx]
  442.  
  443. init_0: ; 80x25 text
  444.     mov    ax,3
  445.     int    10h
  446.     mov    cx,80
  447.     mov    dx,25
  448.     ret
  449.  
  450. init_1: ; default text
  451.     mov    cx,def_tw
  452.     mov    dx,def_th
  453.     jmp    init_2
  454.  
  455. init_2_table    label    word
  456.     dw    01h, 40, 25
  457.     dw    03h, 80, 25
  458.     dw    50h, 80, 30
  459.     dw    51h, 80, 43
  460.     dw    52h, 80, 60
  461.     dw    53h, 132, 25
  462.     dw    54h, 132, 30
  463.     dw    55h, 132, 43
  464.     dw    56h, 132, 60
  465. init_2_tend    label    word
  466.  
  467. init_2: ; CX*DX text
  468.     mov    si,offset init_2_table
  469. init_2a:
  470.     cmp    [si+2],cx
  471.     jb    init_2b
  472.     cmp    [si+4],dx
  473.     jb    init_2b
  474.     ; got a big enough one!
  475.     jmp    init_2c
  476. init_2b:
  477.     cmp    si,offset init_2_tend - 6
  478.     je    init_2c
  479.     add    si,6
  480.     jmp    init_2a
  481. init_2c:
  482.     mov    ax,[si]
  483.     push    si
  484.     int    10h
  485.     pop    si
  486.     mov    cx,[si+2]
  487.     mov    dx,[si+4]
  488.     ret
  489.  
  490. init_3: ; biggest text
  491.     mov    ax,[init_2_tend-6]
  492.     int    10h
  493.     mov    cx,[init_2_tend-4]
  494.     mov    dx,[init_2_tend-2]
  495.     ret
  496.  
  497. init_4: ; 320x200 graphics
  498.     mov    ax,13h
  499.     int    10h
  500.     mov    cx,320
  501.     mov    dx,200
  502.     ret
  503.  
  504. init_5: ; default graphics - should be 640x480 if supported
  505.     mov    cx,def_gw
  506.     mov    dx,def_gh
  507.     jmp    init_6
  508.  
  509. init_6_table    label    word
  510.     dw    13h, 320, 200
  511.     dw    5ch, 640, 400
  512.     dw    5dh, 640, 480
  513.     dw    5eh, 800, 600
  514.     dw    62h, 1024, 768
  515. init_6_tend    label    word
  516.  
  517. init_6: ; CX*DX graphics
  518.     mov    si,offset init_6_table
  519. init_6a:
  520.     cmp    [si+2],cx
  521.     jb    init_6b
  522.     cmp    [si+4],dx
  523.     jb    init_6b
  524.     ; got a big enough one!
  525.     jmp    init_6c
  526. init_6b:
  527.     cmp    si,offset init_6_tend - 6
  528.     je    init_6c
  529.     add    si,6
  530.     jmp    init_6a
  531. init_6c:
  532.     mov    ax,[si]
  533.     push    si
  534.     int    10h
  535.     pop    si
  536.     mov    cx,[si+2]
  537.     mov    dx,[si+4]
  538.     ret
  539.  
  540. init_7: ; biggest non-interlaced graphics
  541.     mov    ax,5eh
  542.     int    10h
  543.     mov    cx,800
  544.     mov    dx,600
  545.     ret
  546.  
  547. init_8: ; biggest graphics
  548.     mov    ax,62h
  549.     int    10h
  550.     mov    cx,1024
  551.     mov    dx,768
  552.     ret
  553.  
  554. init_routine    endp
  555.  
  556. ;--------------------------------------------------------------------------
  557. ; Entry: AH=read page
  558. ;     AL=write page
  559. ;
  560. ; NOTE: This runs in protected mode!  Don't mess with the segment registers!
  561. ; This code must be relocatable and may not reference any data!
  562. ;
  563. ; Exit: VGA configured.
  564. ;    AX,BX,CX,DX,SI,DI may be trashed
  565. ;
  566. ; Code derived from VGAKIT version 3.5
  567. ;    Copyright 1988,89,90 John Bridges
  568.  
  569.     assume  ds:nothing, es:nothing
  570.  
  571. paging_routine  proc    far
  572.     mov    cx,ax        ;save page
  573.     mov    dx,3ceh        ;set pagesize to 64k
  574.     mov    al,6
  575.     out    dx,al
  576.     inc    dl
  577.     in    al,dx
  578.     dec    dl
  579.     or    al,4
  580.     mov    ah,al
  581.     mov    al,6
  582.     out    dx,ax
  583.  
  584.     mov    dl,0c4h        ;switch to BPS mode
  585.     mov    al,0bh
  586.     out    dx,al
  587.     inc    dl
  588.     in    al,dx
  589.     dec    dl
  590.  
  591.     mov    ah,cl
  592.     xor    ah,2
  593.     mov    dx,3c4h
  594.     mov    al,0eh
  595.     out    dx,ax
  596.     ret
  597.  
  598. paging_routine  endp
  599.  
  600. ;--------------------------------------------------------------------------
  601.  
  602. cseg    ends
  603.     end
  604.  
  605. ; End of file TRID89N.ASM
  606.  
  607.  
  608. /* End of mail */
  609.  
  610.